package com.mk.service.web;

import act.controller.Controller;
import com.alibaba.fastjson.JSON;
import com.github.d925529.apidoc.ApiHttpMethod;
import com.github.d925529.apidoc.annotation.*;
import com.mk.domain.TOrder;
import com.mk.domain.TOrderLogistics;
import com.mk.interceptor.ITranslate;
import com.mk.util.S2;
import com.mk.util.kuaidi.KuaiDiUtils;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import org.osgl.mvc.annotation.PutAction;
import org.osgl.mvc.annotation.With;
import org.osgl.util.S;

import javax.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 说明：物流信息表前台接口
 * 作者：anonymous 
 * 日期：2018-10-31 14:40:14 
 * 版本：1.0.0
 */
@Controller("tOrderLogistics")
@Api(group = "wb",title = "物流信息表服务", path = "/tOrderLogistics")
@SuppressWarnings("unused")
public class TOrderLogisticsService extends BaseWebService {
    @Inject
    private TOrderLogistics.Mapper tOrderLogisticsMapper;
    @Inject
    private TOrder.Mapper tOrderMapper;

    /**
     * 根据订单编号,查询相应的快递发货记录
     * @param orderid
     * @return
     */
    @GetAction("orderkuaidi.json")
    @With({WbILogin.class, ITranslate.class})
    public Map<String, Object> orderkuaidi(String orderid) {
        Map<String,Object> map = tOrderMapper.queryDetailImgByOrderid(orderid);
        if(map!=null){
            return map;
        }
        return new HashMap<>();
    }

    /**
     * 根据物流公司编码和快递编号查询快递详情
     * @param logisticscode
     * @param logisticsnumber
     * @return
     */
    @GetAction("kuaididetail.json")
    @With({WbILogin.class, ITranslate.class})
    public Map<String, Object> kuaididetail(String logisticscode,String logisticsnumber) {
        String kuaidi = KuaiDiUtils.getLogisticsInformation(logisticscode,logisticsnumber);
        if(S.isNotBlank(kuaidi)){
            return JSON.parseObject(kuaidi,Map.class);
        }
        return new HashMap<>();

    }
}
